
<template>
  <el-dialog
    v-dialogDrag
    title="导出文件"
    :visible.sync="params.visible"
    :close-on-click-modal="false"
    width="30%"
  >
    <el-form
      ref="form"
      label-width="80px"
      :model="formData"
      :rules="rules"
    >
      <el-form-item
        label="文件名称"
        prop="fileName"
      >
        <el-input v-model.trim="formData.fileName" />
      </el-form-item>

    </el-form>
    <span
      slot="footer"
      class="dialog-footer"
    >
      <dialog-btn />
    </span>
  </el-dialog>
</template>
<script>
export default {
  name: 'ExportFile',
  props: {
    params: {
      type: Object,
      default() {
        return {
          visible: false

        }
      }
    }
  },
  data() {
    return {
      visible: false,
      // 保存传来得数据
      formData: {},
      rules: {
        fileName: [{ required: true, message: '文件名称不能为空，请输入', trigger: 'blur' }]
      }
    }
  },
  created() {
    this.formData = {
      fileName: ''
    }
  },
  methods: {
    confirm() {
      this.$refs.form.validate(async valid => {
        if (!valid) return // 如果没有填入则不再执行以下代码
        // 如果当前传入回调则使用回调
        if (this.params.confirm !== undefined) {
          this.params.confirm(this.formData)
        } else {
          this.$emit('confirm', this.formData)
        }
      })
    }
  }

}
</script>
<style lang="scss" scoped>
</style>

